package com.zhu.tool_test.starke.util.lang;

import java.util.*;

/**
 * @author Qicheng Peng
 * @version V1.0
 * @description 字符串工具类
 * @date Create at 2018/7/21
 */
public class Strings {
    public static boolean isNullOrEmpty(String... strings) {
        for (String string : strings) {
            if (string == null || string.length() == 0) {
                return true;
            }
        }
        return false;
    }

    // 计算数组数量最多
    public static List<String> theLargestNumber(String[] sList) {
        Map<String, Integer> map = new HashMap<>();
        for (String s : sList) {
            if (!Objects.isNull(map.get(s))) {
                map.put(s, map.get(s) + 1);
            } else {
                map.put(s, 1);
            }
        }
        map.size();
        Set<String> strings = map.keySet();
        int max = 0;
        List<String> maxStirngs = new ArrayList<>();
        // 算出最大的数值
        for (String key : strings) {
            if (map.get(key) > max) {
                max = map.get(key);
            }
            map.get(key);
        }
        // 算出哪几个是最大的数值
        for (String key : strings) {
            if (map.get(key) == max) {
                maxStirngs.add(key);
            }
        }
        return maxStirngs;
    }

    public static boolean isNotNullOrEmpty(String... strings) {
        return !isNullOrEmpty(strings);
    }
}
